/**
 * NoticeBtnItem
 * @Author ace.ch
 * @Date 2018/4/4 10:33
 */
class NoticeBtnItem extends BaseSprite {

    btn: eui.RadioButton;
    tips: eui.Image;

    active: any;

    constructor() {
        super();

        this.skinName = 'NoticeBtnItemSkin';
    }

    childrenCreated() {
        super.childrenCreated();

        this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
    }

    private clickHandler(e: egret.TouchEvent) {
        if (this.active.hasOwnProperty('tip')) {

            this.tips.visible = false;

            delete this.active['tip'];

            gameManager.i.dispatchEvent(GameEventType.UPDATE_NOTICE);
        }
    }

    update(act: any) {
        this.active = act;

        this.btn.label = act.title;
        this.tips.visible = act.hasOwnProperty('tip');
    }

    get label() {
        return this.btn.label;
    }

    set selected(b: boolean) {
        this.btn.selected = b;
    }
}